package c.e.a.b.f.b;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import c.e.a.b.b.j.d;

/* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */
public final class h extends SQLiteOpenHelper {
    public final /* synthetic */ g a;

    public h(g gVar, Context context, String str) {
        this.a = gVar;
        super(context, str, null, 1);
    }

    /* JADX WARNING: Removed duplicated region for block: B:20:0x0083  */
    /* JADX WARNING: Removed duplicated region for block: B:7:0x0027 A:{SYNTHETIC, Splitter:B:7:0x0027} */
    public final android.database.sqlite.SQLiteDatabase getWritableDatabase() {
        /*
        r7 = this;
        r0 = r7.a;
        r0 = r0.e;
        r1 = r0.b;
        r3 = 0;
        r5 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1));
        if (r5 != 0) goto L_0x000d;
    L_0x000c:
        goto L_0x0022;
    L_0x000d:
        r1 = r0.a;
        r1 = (c.e.a.b.b.j.c) r1;
        java.util.Objects.requireNonNull(r1);
        r1 = android.os.SystemClock.elapsedRealtime();
        r5 = r0.b;
        r1 = r1 - r5;
        r5 = 3600000; // 0x36ee80 float:5.044674E-39 double:1.7786363E-317;
        r0 = (r1 > r5 ? 1 : (r1 == r5 ? 0 : -1));
        if (r0 < 0) goto L_0x0024;
    L_0x0022:
        r0 = 1;
        goto L_0x0025;
    L_0x0024:
        r0 = 0;
    L_0x0025:
        if (r0 == 0) goto L_0x0083;
    L_0x0027:
        r0 = super.getWritableDatabase();	 Catch:{ SQLiteException -> 0x002c }
        return r0;
    L_0x002c:
        r0 = r7.a;
        r0 = r0.e;
        r1 = r0.a;
        r1 = (c.e.a.b.b.j.c) r1;
        java.util.Objects.requireNonNull(r1);
        r1 = android.os.SystemClock.elapsedRealtime();
        r0.b = r1;
        r0 = r7.a;
        r0 = r0.d();
        r0 = r0.f;
        r1 = "Opening the database failed, dropping and recreating it";
        r0.a(r1);
        r0 = "google_app_measurement.db";
        r1 = r7.a;
        r1 = r1.a;
        r1 = r1.a;
        r1 = r1.getDatabasePath(r0);
        r1 = r1.delete();
        if (r1 != 0) goto L_0x0069;
    L_0x005c:
        r1 = r7.a;
        r1 = r1.d();
        r1 = r1.f;
        r2 = "Failed to delete corrupted db file";
        r1.b(r2, r0);
    L_0x0069:
        r0 = super.getWritableDatabase();	 Catch:{ SQLiteException -> 0x0074 }
        r1 = r7.a;	 Catch:{ SQLiteException -> 0x0074 }
        r1 = r1.e;	 Catch:{ SQLiteException -> 0x0074 }
        r1.b = r3;	 Catch:{ SQLiteException -> 0x0074 }
        return r0;
    L_0x0074:
        r0 = move-exception;
        r1 = r7.a;
        r1 = r1.d();
        r1 = r1.f;
        r2 = "Failed to open freshly created database";
        r1.b(r2, r0);
        throw r0;
    L_0x0083:
        r0 = new android.database.sqlite.SQLiteException;
        r1 = "Database open failed";
        r0.<init>(r1);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.h.getWritableDatabase():android.database.sqlite.SQLiteDatabase");
    }

    public final void onCreate(SQLiteDatabase sQLiteDatabase) {
        d.E(this.a.d(), sQLiteDatabase);
    }

    public final void onDowngrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    public final void onOpen(SQLiteDatabase sQLiteDatabase) {
        SQLiteDatabase sQLiteDatabase2 = sQLiteDatabase;
        d.F(this.a.d(), sQLiteDatabase2, "events", "CREATE TABLE IF NOT EXISTS events ( app_id TEXT NOT NULL, name TEXT NOT NULL, lifetime_count INTEGER NOT NULL, current_bundle_count INTEGER NOT NULL, last_fire_timestamp INTEGER NOT NULL, PRIMARY KEY (app_id, name)) ;", "app_id,name,lifetime_count,current_bundle_count,last_fire_timestamp", g.f);
        d.F(this.a.d(), sQLiteDatabase2, "conditional_properties", "CREATE TABLE IF NOT EXISTS conditional_properties ( app_id TEXT NOT NULL, origin TEXT NOT NULL, name TEXT NOT NULL, value BLOB NOT NULL, creation_timestamp INTEGER NOT NULL, active INTEGER NOT NULL, trigger_event_name TEXT, trigger_timeout INTEGER NOT NULL, timed_out_event BLOB,triggered_event BLOB, triggered_timestamp INTEGER NOT NULL, time_to_live INTEGER NOT NULL, expired_event BLOB, PRIMARY KEY (app_id, name)) ;", "app_id,origin,name,value,active,trigger_event_name,trigger_timeout,creation_timestamp,timed_out_event,triggered_event,triggered_timestamp,time_to_live,expired_event", null);
        d.F(this.a.d(), sQLiteDatabase2, "user_attributes", "CREATE TABLE IF NOT EXISTS user_attributes ( app_id TEXT NOT NULL, name TEXT NOT NULL, set_timestamp INTEGER NOT NULL, value BLOB NOT NULL, PRIMARY KEY (app_id, name)) ;", "app_id,name,set_timestamp,value", g.g);
        d.F(this.a.d(), sQLiteDatabase2, "apps", "CREATE TABLE IF NOT EXISTS apps ( app_id TEXT NOT NULL, app_instance_id TEXT, gmp_app_id TEXT, resettable_device_id_hash TEXT, last_bundle_index INTEGER NOT NULL, last_bundle_end_timestamp INTEGER NOT NULL, PRIMARY KEY (app_id)) ;", "app_id,app_instance_id,gmp_app_id,resettable_device_id_hash,last_bundle_index,last_bundle_end_timestamp", g.h);
        d.F(this.a.d(), sQLiteDatabase2, "queue", "CREATE TABLE IF NOT EXISTS queue ( app_id TEXT NOT NULL, bundle_end_timestamp INTEGER NOT NULL, data BLOB NOT NULL);", "app_id,bundle_end_timestamp,data", g.j);
        d.F(this.a.d(), sQLiteDatabase2, "raw_events_metadata", "CREATE TABLE IF NOT EXISTS raw_events_metadata ( app_id TEXT NOT NULL, metadata_fingerprint INTEGER NOT NULL, metadata BLOB NOT NULL, PRIMARY KEY (app_id, metadata_fingerprint));", "app_id,metadata_fingerprint,metadata", null);
        d.F(this.a.d(), sQLiteDatabase2, "raw_events", "CREATE TABLE IF NOT EXISTS raw_events ( app_id TEXT NOT NULL, name TEXT NOT NULL, timestamp INTEGER NOT NULL, metadata_fingerprint INTEGER NOT NULL, data BLOB NOT NULL);", "app_id,name,timestamp,metadata_fingerprint,data", g.i);
        d.F(this.a.d(), sQLiteDatabase2, "event_filters", "CREATE TABLE IF NOT EXISTS event_filters ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, filter_id INTEGER NOT NULL, event_name TEXT NOT NULL, data BLOB NOT NULL, PRIMARY KEY (app_id, event_name, audience_id, filter_id));", "app_id,audience_id,filter_id,event_name,data", g.k);
        d.F(this.a.d(), sQLiteDatabase2, "property_filters", "CREATE TABLE IF NOT EXISTS property_filters ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, filter_id INTEGER NOT NULL, property_name TEXT NOT NULL, data BLOB NOT NULL, PRIMARY KEY (app_id, property_name, audience_id, filter_id));", "app_id,audience_id,filter_id,property_name,data", g.l);
        d.F(this.a.d(), sQLiteDatabase2, "audience_filter_values", "CREATE TABLE IF NOT EXISTS audience_filter_values ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, current_results BLOB, PRIMARY KEY (app_id, audience_id));", "app_id,audience_id,current_results", null);
        d.F(this.a.d(), sQLiteDatabase2, "app2", "CREATE TABLE IF NOT EXISTS app2 ( app_id TEXT NOT NULL, first_open_count INTEGER NOT NULL, PRIMARY KEY (app_id));", "app_id,first_open_count", g.m);
        d.F(this.a.d(), sQLiteDatabase2, "main_event_params", "CREATE TABLE IF NOT EXISTS main_event_params ( app_id TEXT NOT NULL, event_id TEXT NOT NULL, children_to_process INTEGER NOT NULL, main_event BLOB NOT NULL, PRIMARY KEY (app_id));", "app_id,event_id,children_to_process,main_event", null);
        d.F(this.a.d(), sQLiteDatabase2, "default_event_params", "CREATE TABLE IF NOT EXISTS default_event_params ( app_id TEXT NOT NULL, parameters BLOB NOT NULL, PRIMARY KEY (app_id));", "app_id,parameters", null);
        d.F(this.a.d(), sQLiteDatabase2, "consent_settings", "CREATE TABLE IF NOT EXISTS consent_settings ( app_id TEXT NOT NULL, consent_state TEXT NOT NULL, PRIMARY KEY (app_id));", "app_id,consent_state", null);
    }

    public final void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }
}
